package com.mt.api.modules.controller;


import com.mt.api.modules.domain.bo.BrandPaymentAddBo;
import com.mt.api.modules.domain.vo.BrandPaymentVo;
import com.mt.api.modules.service.IBrandPaymentService;
import com.mt.api.util.ParamsValid;
import com.mt.common.response.WebResponse;
import com.mt.common.response.WebResponseUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: plover
 * @Date: 2022-05-01
 * @Description:
 */
@RestController
@RequestMapping("/app/brand/payment")
@RequiredArgsConstructor
public class BrandPaymentController {

    @Autowired
    private final IBrandPaymentService brandPaymentService;

    @GetMapping("/info")
    public WebResponse<BrandPaymentVo> getPaymentInfo() {
        return brandPaymentService.getPaymentInfo();
    }

    @PostMapping("/add")
    public WebResponse addPayment(@RequestBody BrandPaymentAddBo bo) {
        ParamsValid valid = new ParamsValid();
        valid.validNotNull("收款码不能为空", bo.getQrcodeUrl());
        if (!valid.isValid()) {
            return WebResponseUtils.errorParam(valid.getMsg());
        }
        return brandPaymentService.addPayment(bo);
    }
}